
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

struct Pos{
    int row;
    int col;
    Pos(int row,int col):row(row),col(col){

    }
};

class OneLoop{
public:
    std::list<Pos> puted;
    std::vector<std::vector<int>> vec2;
    int max=0;
    bool putable(int row,int col){
        for(auto p:puted){
            if(row==p.row||col==p.col||
                abs(p.row-row)==abs(p.col-col)
            ){
                return false;
            }
        }
        return true;
    }
    void put_on_row(int row){
        if(row==8){
            int sum=0;
            for(auto p:puted){
                sum+=vec2[p.row][p.col];
            }
            if(sum>max){
                max=sum;
            }
            return;
        }
        for(int i=0;i<8;i++){
            if(putable(row,i)){
                puted.push_back(Pos(row,i));
                put_on_row(row+1);
                puted.pop_back();
            }
        }
    }
    void input(){
        for (int i = 0; i <8 ; ++i) {
            std::vector<int> vec;
            for (int j = 0; j < 8; ++j) {
                int a;std::cin>>a;
                vec.push_back(a);
            }
            vec2.push_back(vec);
        }
    }
    void run(
//            std::string&s1,std::string&s2
            ){
        input();
        put_on_row(0);
        std::cout<<max<<std::endl;
    }
};
class Solution {
public:
    void run() {

        bool first = true;
        int a,b,c,d,e;
//        std::string s1,s2;
//        while (
//                std::cin>>a
////                std::getline(std::cin,s1)
//                )
        {
//            std::getline(std::cin,s2);
            OneLoop loop;
            loop.run();
        }
    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

